<?php
namespace app\index\controller;
// use app\index\
class Contact extends Base
{
    public function index()
    {      
        $id=request()->param('id');
        $viewPage=$this->getIndexPage($id);        
        $systemt=db("systemt");
        $channel=db("channel");
                
        $pid=$channel->where("id=".$id)->value("pid");
        if($pid > 0){
            $gcid=$pid;
            $pcid=$id;
            $lchannel=$this->get_left_channel($pid);
            $fname=$channel->where("id",$pid)->value("name");
        }else{
            $gcid=$id;
            $pcid=$channel->where("pid=".$id)->value("id");
            $lchannel=$this->get_left_channel($id);
            $fname=$channel->where("id",$id)->value("name");
        }
        $where['id']=1;
        
        $mess=$systemt->where($where)->find();
        if($mess['qrcode']){
            $mess['annexes']=db("filex")->where("id=".$mess['qrcode'])->value("thumb");
        }

        $gnavName=$channel->where("id=".$gcid)->value("name");

        $pnavName=$channel->where("id=".$pcid)->value("name");
        // SEO META关键字配置
        $meta=$this->meta;
        $meta['title']=$pnavName.' '.$gnavName.' '.$meta['title'];
        if($mess['keywords']){
            $meta['keywords']=$mess['keywords'];
        }else{
            $meta['keywords']=$pnavName.$gnavName.$meta['keywords'];
        }
        if($mess['descript']){
            $meta['descript']=$mess['descript'];
        }else{
            $meta['descript']=$pnavName.$gnavName.$meta['descript'];
        }
        $this->assign("meta",$meta);
        $modelx=$channel->where("id",$gcid)->value("modelx");
        $modelxMark=db("modelx")->where("id=".$modelx)->value("mark");
        $this->assign("modelxMark",$modelxMark);
        
        $banner=$this->get_banner($gcid);
        $this->assign("banner",$banner);
        $this->assign("pnavName",$pnavName);
        $this->assign("gnavName",$gnavName);
        $this->assign("lchannel",$lchannel);
        $this->assign("cid",$cid);
        $this->assign("gcid",$gcid);
        $this->assign("pcid",$pcid);
        $this->assign("fname",$fname);
        $this->assign("mess",$mess);
        return view($viewPage);
    }
    public function map()
    {
        $systemt=db("systemt");
        $where['id']=1;
        $mess=$systemt->where($where)->find();
        $this->assign("mess",$mess);
        return view('map');
    }
}
